@@ -0,0 +1,7 @@  | 
            ||
| 1 | 
                +To Do  | 
            |
| 2 | 
                +======  | 
            |
| 3 | 
                +  | 
            |
| 4 | 
                +- Repeated requests to the same domain, ends up causing a block. This app should be storing queries for 12-24 hours.  | 
            |
| 5 | 
                +  | 
            |
| 6 | 
                +- add some error checking  | 
            |
| 7 | 
                +  | 
            
                @@ -8,13 +8,31 @@ get '/' do  | 
            ||
| 8 | 8 | 
                end  | 
            
| 9 | 9 | 
                 | 
            
| 10 | 10 | 
                get '/lookup' do  | 
            
| 11 | 
                - @lookup_url = params[:url]  | 
            |
| 12 | 
                - @lookup_info = Whois.query(params[:url]).to_s.gsub(/\n/, '<br>')  | 
            |
| 11 | 
                + @lookup_info = Whois.query(params[:url])  | 
            |
| 12 | 
                +	@formatted_response = {
               | 
            |
| 13 | 
                + "domain" => @lookup_info.domain,  | 
            |
| 14 | 
                + "created_on" => @lookup_info.created_on,  | 
            |
| 15 | 
                + "expires_on" => @lookup_info.expires_on,  | 
            |
| 16 | 
                + "whois_server" => @lookup_info.referral_whois,  | 
            |
| 17 | 
                + "nameservers" => @lookup_info.nameservers,  | 
            |
| 18 | 
                + "admin_contacts" => @lookup_info.admin_contacts,  | 
            |
| 19 | 
                + "techical_contacts" => @lookup_info.technical_contacts,  | 
            |
| 20 | 
                + "detailed" => @lookup_info.to_s.gsub(/\n/, '<br>')  | 
            |
| 21 | 
                + }  | 
            |
| 22 | 
                + puts @lookup_info.admin_contacts  | 
            |
| 13 | 23 | 
                haml :lookup  | 
            
| 14 | 24 | 
                end  | 
            
| 15 | 25 | 
                 | 
            
| 16 | 26 | 
                get '/lookup.json' do  | 
            
| 17 | 27 | 
                @lookup_info = Whois.query(params[:url])  | 
            
| 18 | 28 | 
                content_type :json  | 
            
| 19 | 
                - @lookup_info.to_json  | 
            |
| 29 | 
                +	{ :domain => @lookup_info.domain,
               | 
            |
| 30 | 
                + :created_on => @lookup_info.created_on,  | 
            |
| 31 | 
                + :expires_on => @lookup_info.expires_on,  | 
            |
| 32 | 
                + :whois_server => @lookup_info.referral_whois,  | 
            |
| 33 | 
                + :nameservers => @lookup_info.nameservers,  | 
            |
| 34 | 
                + :admin_contacts => @lookup_info.admin_contacts,  | 
            |
| 35 | 
                + :techical_contacts => @lookup_info.technical_contacts,  | 
            |
| 36 | 
                + :detailed => @lookup_info  | 
            |
| 37 | 
                + }.to_json  | 
            |
| 20 | 38 | 
                end  | 
            
                @@ -3,7 +3,7 @@  | 
            ||
| 3 | 3 | 
                %head  | 
            
| 4 | 4 | 
                %title A free whois API service  | 
            
| 5 | 5 | 
                %body  | 
            
| 6 | 
                - %p "Go to whois.com/jasonormand.com"  | 
            |
| 6 | 
                + %p Just enter a URL, to do a WHOIS lookup.  | 
            |
| 7 | 7 | 
                 | 
            
| 8 | 8 | 
                 		%form{ :action => "/lookup", :method => "get"}
               | 
            
| 9 | 9 | 
                 			%input{ :type => "text", :name => "url"}
               | 
            
                @@ -3,8 +3,37 @@  | 
            ||
| 3 | 3 | 
                %head  | 
            
| 4 | 4 | 
                %title A free whois API service  | 
            
| 5 | 5 | 
                %body  | 
            
| 6 | 
                -		%div{:style => "border: solid 5px black; padding: 15px; margin-bottom: 15px;"}
               | 
            |
| 7 | 
                - = @lookup_url  | 
            |
| 8 | 
                -		%div{:style => "border: solid 5px black; padding: 15px;"}
               | 
            |
| 9 | 
                - = @lookup_info  | 
            |
| 6 | 
                +  | 
            |
| 7 | 
                + %h3 URL  | 
            |
| 8 | 
                +		%div{:style => "border: solid 1px black; padding: 10px; border-radius: 15px"}
               | 
            |
| 9 | 
                + = @formatted_response["domain"]  | 
            |
| 10 | 
                +  | 
            |
| 11 | 
                + %h3 Admin Contact  | 
            |
| 12 | 
                +		%div{:style => "border: solid 1px black; padding: 10px; border-radius: 15px"}
               | 
            |
| 13 | 
                + = @formatted_response["admin_contacts"]  | 
            |
| 14 | 
                +  | 
            |
| 15 | 
                + %h3 Technical Contact  | 
            |
| 16 | 
                +		%div{:style => "border: solid 1px black; padding: 10px; border-radius: 15px"}
               | 
            |
| 17 | 
                + = @formatted_response["technical_contacts"]  | 
            |
| 18 | 
                +  | 
            |
| 19 | 
                + %h3 Create Date  | 
            |
| 20 | 
                +		%div{:style => "border: solid 1px black; padding: 10px; border-radius: 15px"}
               | 
            |
| 21 | 
                + = @formatted_response["created_on"]  | 
            |
| 22 | 
                +  | 
            |
| 23 | 
                + %h3 Expire Date  | 
            |
| 24 | 
                +		%div{:style => "border: solid 1px black; padding: 10px; border-radius: 15px"}
               | 
            |
| 25 | 
                + = @formatted_response["expires_on"]  | 
            |
| 26 | 
                +  | 
            |
| 27 | 
                + %h3 WHOIS Server  | 
            |
| 28 | 
                +		%div{:style => "border: solid 1px black; padding: 10px; border-radius: 15px"}
               | 
            |
| 29 | 
                + = @formatted_response["whois_server"]  | 
            |
| 30 | 
                +  | 
            |
| 31 | 
                + %h3 Nameservers  | 
            |
| 32 | 
                +		%div{:style => "border: solid 1px black; padding: 10px; border-radius: 15px"}
               | 
            |
| 33 | 
                + - @formatted_response["nameservers"].each do |name|  | 
            |
| 34 | 
                + = name.to_s + " <br />"  | 
            |
| 35 | 
                +  | 
            |
| 36 | 
                + %h3 Detailed Response  | 
            |
| 37 | 
                +		%div{:style => "border: solid 1px black; padding: 10px; border-radius: 15px"}
               | 
            |
| 38 | 
                + = @formatted_response["detailed"]  | 
            |
| 10 | 39 | 
                 |